#!/bin/sh
cd `dirname $0`

XENGINE_HOME=`pwd`
XENGINE_DB=$XENGINE_HOME/db

HOSTNAME=`hostname`
XENGINE_NODE=xengine@$HOSTNAME

SSH_DIR=${XENGINE_HOME}/.ssh
SSH_PORT=8888

[ -f $XENGINE_HOME/etc/xengine.cfg ] && .  $XENGINE_HOME/etc/xengine.cfg



exec erl -pa $PWD/ebin $PWD/deps/*/ebin \
                -boot start_sasl  \
                -s reloader   \
                -s xengine   \
                -name $XENGINE_NODE \
                +K true +P 10240000  \
                -config  etc/xengine.config \
		-setcookie abcd1234   \
        -mnesia dir ${XENGINE_DB} \
		-mnesia extra_db_nodes ${EXTRA_DB_NODES} \
		-env ssh.dir ${SSH_DIR} \
		-env ssh.port ${SSH_PORT} \
				$*
